//
//  Material.h
//  RenderV1
//
//  Created by 黄翔 on 2019/10/20.
//  Copyright © 2019 黄翔. All rights reserved.
//

#ifndef Material_h
#define Material_h

#include <fstream>
#include <sstream>
#include <iostream>
#include <vector>
#include "Shader.h"
#include "Texture.h"
#include "PropertyImp.h"
#include "ReferenceCounted.h"

namespace hxe
{
    class Material : public ReferenceCounted
    {
    public:
        void prepareDraw();

        Shader* getShader() const;

        void setBool(const std::string &name, bool value);

        void setInt(const std::string &name, int value);

        void setFloat(const std::string &name, float value);
        
        void setVector4(const std::string &name, const Vector4& v);
        
        void setVector3(const std::string &name, const Vector3& v);

        void setMatrix(const std::string &name, const Matrix4x4 &matrix);

        void addTexture(Texture* texture);

    private:
        Property* findProperty(const std::string &name);
        std::string handleProperty(std::ifstream& matFile);

    public:
        int polygonMode;
        int cull;
        int blend;
        int depthTest;

    public:
        Material(Shader* shader, std::vector<Texture*> textures);
        Material(Shader* shader);
        Material(Material* source);
        Material(std::string path);
        Material();
        ~Material();
        
    private:
        Shader* shader;
        std::vector<Texture*> textures;
        std::vector<Property*> properties;
    };
}

#endif /* Material_h */
